package com.itheima.service.impl;

import com.itheima.mapper.DeptLogMapper;
import com.itheima.pojo.DeptLog;
import com.itheima.service.DeptLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class DeptLogServiceImpl implements DeptLogService {

    @Autowired
    private DeptLogMapper deptLogMapper;

    //REQUIRED：如果有事务，就加入到事务，如果没有事务，新建一个事务
    //REQUIRES_NEW：如果有事务，新建一个事务，如果没有事务，新建一个事务
    @Transactional(propagation = Propagation.REQUIRES_NEW) //propagation：控制事务的传播行为
    @Override
    public void insert(DeptLog deptLog) {

        deptLogMapper.insert(deptLog);

    }
}
